/*
* @Author: z.p
* @Project: Zdotp
* @Date: 2025年01月14日
* @Description: controller处理基类
*/

using Zdotp.Actor.Packet;

namespace Zdotp.Actor.Controller;

public interface IActorController
{
    void Control(ActorBase actor, MessageInfo info, MailObject message);
}
public abstract class ActorController<A, T> : IActorController where A : ActorBase where T : MailObject, new()
{
    public void Control(ActorBase actor, MessageInfo info, MailObject message)
    {
        if (message is not T packet || actor is not A act)
        {
            return;
        }
        Run(act, act.MyActorSystem, info, packet);
    }

    protected abstract void Run(A actor, ActorSystem system, MessageInfo info, T data);
}